package day01.loop;

/**
 * 计算 2 + 4 + 6 + … + 100 的值。
 * @since 15:35
 * @author wuguidong@cskaoyan.onaliyun.com
 */
public class CycleSumDemo {
    public static void main(String[] args) {
        int sum = 0;
        for (int i = 2; i <= 100; i += 2) {
            sum += i;
        }
        System.out.println(sum);
        // 相应的，你还可以求1 + 3 + 5 + ... + 99的值
        int sum2 = 0;
        for (int i = 1; i <= 100; i += 2) {
            sum2 += i;
        }
        System.out.println(sum2);

    }
}
